﻿@model CuongHanh.Models.ParentMaterial
@(Html.X()
          .FormPanel()
          .Region(Region.Center)
          .Border(false)
          .StyleSpec("background-color:white;")
          .Padding(10)
          .Items(form =>
                 {
                     form.Add(Html.X()
                             .HiddenFor(m => m.ChildStyleId));
                     form.Add(Html.X()
                             .HiddenFor(m => m.ParentStyleId));
                     form.Add(Html.X()
                             .ComboBoxFor(m => m.ParentMaterialId)
                             .FieldLabel("Chất liệu")
                             .Width(500)
                             .ForceSelection(true)
                             .DisplayField("Name")
                             .ValueField("Id")
                             .EmptyText("Danh mục")
                             .AllowBlank(false)
                             .ReadOnly(true)
                             .Store(Html.X().Store()
                                     .AutoLoad(true)
                                     .Model(Html.X().Model()
                                             .IDProperty("Id")
                                             .Fields(
                                                     "Id",
                                                     "Name"
                                             )
                                     )
                                     .Proxy(Html.X().AjaxProxy()
                                             .Json(true)
                                             .Url(Url.Action("GetMaterialsOfParentCombo"))
                                             .ActionMethods(v => v.Read = HttpMethod.POST)
                                             .Reader(Html.X().JsonReader().Root("data").TotalProperty("total"))
                                             .ExtraParams(param =>
                                                          {
                                                              param.Add(new Parameter("styleId",
                                                                      Model.ChildStyleId + "",
                                                                      ParameterMode.Value));
                                                              param.Add(new Parameter("parentStyleId",
                                                                      Model.ParentStyleId + "",
                                                                      ParameterMode.Value));
                                                              param.Add(new Parameter("parentMaterialId",
                                                                     Model.ParentMaterialId + "",
                                                                     ParameterMode.Value));
                                                          })
                                     )
                                     .Listeners(ls =>
                                             ls.Load.Handler = "App.ParentMaterialId.setValue(" + Model.ParentMaterialId + ");"
                                     )
                             ));
                     
                     form.Add(Html.X()
                             .NumberFieldFor(m => m.Price)
                             .FieldLabel("Giá")
                             .Width(500)
                             );
                     form.Add(Html.X().FileUploadField()
                             .ID("FileUploadField1")
                             .FieldLabel("Hình ảnh")
                             .Width(300)
                             .EmptyText("chọn file ảnh upload")
                             .ButtonText("")
                             .Icon(Icon.ImageAdd));

                     form.Add(Html.X()
                             .Button()
                             .ID("btUpdate")
                             .Text("Lưu lại")
                             .FormBind(true)
                             .StyleSpec("margin-left:105px;")
                             .DirectClickAction("EditParentMaterial")
                             );
                     form.Add(Html.X()
                             .Button()
                             .ID("btCancel")
                             .Text("Hủy")
                             .StyleSpec("margin-left:10px;")
                             .OnClientClick("App.wdModifyChild.hide();")
                             );
                 }))